﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HTDAL.HTSPC_DBDataSetTableAdapters;

namespace HTspcAppProject
{
    public partial class FormLogin : Form
    {
        public FormLogin()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbxUsr.Text))
            {
                MessageBox.Show("请填写“用户名”！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (string.IsNullOrEmpty(tbxPsd.Text))
            {
                MessageBox.Show("请填写“密码”！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            ht_usrTableAdapter htUsrTa = new ht_usrTableAdapter();
            DataTable usrDt = htUsrTa.GetDataByUsr(tbxUsr.Text);
            if (usrDt.Rows.Count < 1)
            {
                MessageBox.Show("无此用户信息！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                tbxUsr.SelectAll();
                return;
            }
            if (tbxPsd.Text.Equals(Convert.ToString(usrDt.Rows[0]["psd"])))
            {
                Form1 form1 = new Form1();
                this.Hide();
                form1.ShowDialog();
                this.Show();
            }
            else
            {
                MessageBox.Show("登陆密码错误！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                tbxPsd.Clear();
                tbxPsd.Focus();
                return;
            }
        }
    }
}
